<template>
  <div>
    <!-- 歌手歌曲列表 -->
    <div class="singerPage">
      <div class="singersTop">
        <p class="userReturn" @click="userReturn">
          <span class="iconfont icon-xiangzuo"></span>
        </p>
        <div class="lookMage">
          <p>更多歌手</p>
        </div>
      </div>
      <div class="viewsinger">最佳匹配&nbsp;({{ songLists.length }}首)</div>
      <div class="sigerImg">
        <img :src="$route.query.picUrl" alt="" />
        <div>
          歌手：<span>{{ $route.query.singername }}</span>
        </div>
      </div>
      <div>
        <div
          class="everysong"
          v-for="(item, index) in songLists"
          :key="index"
          @click="playSong(item.id,index)"
        >
          <div class="songMsg">
            <h2>{{ item.name }}</h2>
            <h3>
              <span v-for="(key, i) in item.ar" :key="i">
                {{ key.name }} &nbsp;&nbsp;
              </span>
            </h3>
          </div>
          <div class="songPlay">
            <span
              :class="[
                'iconfont',
                flag != index ? 'icon-bofang' : 'icon-tianchongxing-',
                'center',
              ]"
            ></span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { getArtistSongs } from "../../api/singer";
export default {
  data() {
    return {
      flag: null,
      songLists: [],
    };
  },
  methods: {
    getArtistSongsFn() {
      getArtistSongs({ id: this.$route.query.id }).then((data) => {
        console.log(data);
        this.songLists = data.songs;
      });
    },
    userReturn() {
      this.$router.push("/singer");
    },
    playSong(id,index) {
        this.flag = index;
      this.$emit("get-player-id", id);
    },
  },
  created() {
    this.getArtistSongsFn();
    console.log("传递过来的", this.arSinger);
  },
};
</script>

<style lang="less" scoped>
.singerPage {
  .singersTop {
    height: 50px;
    // line-height: 36px;
    background-color: #d4473c;
    display: flex;
    align-items: center;
    user-select: none;
    .userReturn {
      width: 50px;
      height: 50px;
      line-height: 50px;
      text-align: center;

      .iconfont {
        font-size: 20px;
        color: #fff;
      }
    }
    .lookMage {
      margin-left: 10px;
      p {
        font-size: 18px;
        color: #fff;
      }
    }
  }
  .viewsinger {
    height: 30px;
    line-height: 30px;
    font-size: 14px;
    margin: 10px;
    color: #666;
    border-bottom: 1px solid #f2f2f3;
    user-select: none;
  }
  .sigerImg {
    height: 80px;
    margin: 0 10px;
    padding: 10px 0;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #f2f2f3;
    img {
      width: 80px;
      height: 80px;
      background-color: pink;
    }
    div {
      font-size: 18px;
      margin-left: 20px;
      span {
        color: #507daf;
      }
    }
  }
  .everysong {
    color: #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f2f2f3;
    margin: 0 10px;
    padding: 10px 0;
    user-select: none;
    .songMsg {
      font-size: 17px;

      h2 {
        font-size: 16px;
      }
      h3 {
        font-size: 12px;
        color: #888;
      }
    }
    .songPlay {
      user-select: none;
      .iconfont {
        font-size: 22px;
        color: #aaa;
        margin-top: 10px;
        display: inline-block;
      }
    }
  }
}
</style>